#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define LL long long

LL n, a, b;

map<long, long> mp;

int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);	cout.tie(0);
    
    cin >> n >> a >> b;
    LL index, value;
    LL dot = 0;
    for (LL i = 0; i < a; i++)
    {
        cin >> index >> value;
        mp[index] = value;
    }
    for (LL i = 0; i < b; i++)
    {
        cin >> index >> value;
        if (mp[index]!=0)
        {
            dot += value * mp[index];
        }
    }
    cout << dot << endl;
    //system("pause");
}